/*  1:   */ package org.jetbrains.generate.tostring.config;
/*  2:   */ 
/*  3:   */

import com.intellij.codeInsight.generation.GenerateMembersUtil;
import com.intellij.codeInsight.generation.PsiGenerationInfo;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */ 
/* 13:   */ public class InsertAtCaretStrategy
/* 14:   */   implements InsertNewMethodStrategy
/* 15:   */ {
/* 16:34 */   private static final InsertAtCaretStrategy a = new InsertAtCaretStrategy();
/* 17:   */   
/* 18:   */   public static InsertAtCaretStrategy getInstance()
/* 19:   */   {
/* 20:39 */     return a;
/* 21:   */   }
/* 22:   */   
/* 23:   */   public PsiMethod insertNewMethod(PsiClass paramPsiClass, @NotNull PsiMethod paramPsiMethod, Editor paramEditor)
/* 24:   */   {
/* 25:43 */     if (paramPsiMethod == null) {
/* 26:43 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/jetbrains/generate/tostring/config/InsertAtCaretStrategy", "insertNewMethod" }));
/* 27:   */     }
/* 28:43 */     int i = paramEditor != null ? paramEditor.getCaretModel().getOffset() : paramPsiClass.getTextRange().getEndOffset() - 1;
/* 29:44 */     PsiGenerationInfo localPsiGenerationInfo = new PsiGenerationInfo(paramPsiMethod, false);
/* 30:45 */     GenerateMembersUtil.insertMembersAtOffset(paramPsiClass.getContainingFile(), i, Arrays.asList(new PsiGenerationInfo[] { localPsiGenerationInfo }));
/* 31:46 */     return (PsiMethod)localPsiGenerationInfo.getPsiMember();
/* 32:   */   }
/* 33:   */   
/* 34:   */   public String toString()
/* 35:   */   {
/* 36:50 */     return "At caret";
/* 37:   */   }
/* 38:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.generate.tostring.config.InsertAtCaretStrategy

 * JD-Core Version:    0.7.0.1

 */